package com.ruoyi.web.controller.inspection;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.entity.InspectionPeriodName;
import com.ruoyi.system.service.InspectionPeriodNameService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;

/**
 * 巡检周期时间段维护表
 */
@RestController
@RequestMapping("inspectionPeriodName")
public class InspectionPeriodNameController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private InspectionPeriodNameService inspectionPeriodNameService;

    /**
     * 分页查询
     * @param inspectionPeriodName 筛选条件
     * @return 查询结果
     */
    @GetMapping("/list")
    public TableDataInfo queryByPage(InspectionPeriodName inspectionPeriodName) {
        startPage();
        List<InspectionPeriodName> inspectionPeriodNames = this.inspectionPeriodNameService.queryByPage(inspectionPeriodName);
        return getDataTable(inspectionPeriodNames);
    }

    /**
     * 通过主键查询单条数据
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public AjaxResult queryById(@PathVariable("id") Integer id) {
        return AjaxResult.success(this.inspectionPeriodNameService.queryById(id));
    }

    /**
     * 新增数据
     * @return 新增结果
     */
    @PostMapping("/create")
    public AjaxResult add(@RequestBody InspectionPeriodName inspectionPeriodName) {
        return AjaxResult.success(this.inspectionPeriodNameService.insert(inspectionPeriodName));
    }

    /**
     * 编辑数据
     * @return 编辑结果
     */
    @PostMapping("/update")
    public AjaxResult edit(@RequestBody InspectionPeriodName inspectionPeriodName) {
        return AjaxResult.success(this.inspectionPeriodNameService.update(inspectionPeriodName));
    }

    /**
     * 删除数据
     * @param id 主键
     * @return 删除是否成功
     */
    @GetMapping("/delete")
    public AjaxResult deleteById(Integer id) {
        return AjaxResult.success(this.inspectionPeriodNameService.deleteById(id));
    }

}

